import request from '@/utils/request'
const module = '/admin/system/role'
//角色的分类查询带条件
export const GetRoleList = data => {
  return request.post(`${module}/getRole`, data)
}

//删除角色
export const DeleteRole = id => {
  return request.delete(`${module}/deleteRole/${id}`)
}
//添加角色
export const SaveRole = data => {
  return request.post(`${module}/saveRole`, data)
}
//修改角色
export const UpdateRole = data => {
  return request.put(`${module}/updateRole`, data)
}
//查询当前角色列表
export const AssignRole = id => {
  return request.get(`/admin/system/userRole/AssignRoles/${id}`)
}
//修改分配列表
export const updateAssignRoles = (roleIds, userId) => {
  return request.put(
    `/admin/system/userRole/updateAssignRoles/${userId}`,
    roleIds
  )
}

//根据id查询角色拥有的菜单
export const GetMenusByRoleId = roleId => {
  return request.get(`/admin/system/roleMenu/getMenusByRoleId/${roleId}`)
}

//保存菜单
export const AssignMenus = (roleId, menuIds) => {
  return request.put(`/admin/system/roleMenu/assignMenus/${roleId}`, menuIds)
}
